import request from '@/utils/request'

// 查询收款出库单关联列表
export function listConfig(query) {
  return request({
    url: '/project/config/list',
    method: 'get',
    params: query
  })
}

// 查询收款出库单关联详细
export function getConfig(id) {
  return request({
    url: '/project/config/' + id,
    method: 'get'
  })
}

// export function getConfigByFeeKey(feeKey) {
//   return request({
//     url: '/project/config/feeKey/' + feeKey,
//     method: 'get'
//   })
// }



export function getConfigByFeeKey(feeKey) {
  // 对 feeKey 进行 URL 编码，确保 |、空格等被转义
  const encodedFeeKey = encodeURIComponent(feeKey);
  return request({
    url: '/project/config/feeKey/' + encodedFeeKey,
    method: 'get'
  });
}

// 新增收款出库单关联
export function addConfig(data) {
  return request({
    url: '/project/config',
    method: 'post',
    data: data
  })
}

// 修改收款出库单关联
export function updateConfig(data) {
  return request({
    url: '/project/config',
    method: 'put',
    data: data
  })
}


export function saveOrUpdateConfig(data) {
  return request({
    url: '/project/config/saveOrUpdate',
    method: 'put',
    data: data
  })
}

// 删除收款出库单关联
export function delConfig(id) {
  return request({
    url: '/project/config/' + id,
    method: 'delete'
  })
}
